//
//  WmcBaseSystemFieldLabel.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/7/26.
//

import UIKit
import YPBedrock

open class WmcBaseSystemFieldLabel: UILabel {
    // Lifecycle

    override init(frame: CGRect) {
        super.init(frame: frame)
        config()
    }

    @available(*, unavailable)
    public required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // Open

    /// 左边距
    open var leftEdge: CGFloat = 0

    /// 展示模式
    var styleMode: WmcBaseWatermarkTemplateView.StyleMode = .dynamicDraw
    
    /// 内容更新回调
    open var contentReloadBlock: YPBlock.OneParam<String>?

    
    override open var text: String? {
        didSet {
            if let text = text {
                contentReloadBlock?(text)
            }
        }
    }

    /// 配置
    open func config() {}

    override open func drawText(in rect: CGRect) {
        var rect = rect
        rect.origin.x = leftEdge
        rect.size.width -= leftEdge
        super.drawText(in: rect)
    }
}
